package com.drama.outtake.domain;

import com.drama.outtake.domain.enums.Gender;
import com.drama.outtake.util.CustomGenderDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.time.LocalDate;
import java.util.List;

/**
 * @Author : 李先均
 * @Date 2022/12/20 23:47
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@DynamicUpdate
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String openId;
    private String name;
    private Long schoolId;
    private Long phone;
    private String avatar;
    @Enumerated(EnumType.ORDINAL)
    @JsonDeserialize(using = CustomGenderDeserializer.class)
    private Gender gender;
    private LocalDate birthDay;
    @Transient
    private List<Address> addresses;
}
